package io.gitee.pkmer.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author <a href="mailto:1193094618@qq.com">pkmer</a>
 * <br>
 * <a href = "https://gitee.com/pkmer/sonatype-central-publisher">Code Repository</a>
 * At 2024/8/25
 */
public interface CharacterUtil {

     static String characterListToString(List<Character> collect) {
        return collect.stream()
                .map(String::valueOf)
                .collect(Collectors.joining());
    }

    static String shuffle(String originStr){
         List<Character> results = new ArrayList<>(originStr.length());
         for(char c: originStr.toCharArray()){
             results.add(c);
         }
        Collections.shuffle(results);

       return  characterListToString(results);
    }

    /**
     * 获取字符对应的ascii码
     *
     * @param c 单个字符
     * @return ascii码
     */
    public static int getCharacterAsciiCode(Character c) {
        return (int) c;
    }

}
